win32 theme: Make entries and textview work
authorBenjamin Otte <otte@gnome.org>
Tue, 23 Feb 2016 04:05:37 +0000 (05:05 +0100)
committerBenjamin Otte <otte@gnome.org>
Thu, 25 Feb 2016 15:53:22 +0000 (16:53 +0100)
gtk/gtkwin32draw.c
gtk/theme/win32/gtk-win32-base.css

index 0483723d34e3bfbbfbd7a541ec8d54946fe81489..84b50f27734668165dc3c529d3ab6e25fdef92a4 100644 (file)
@@ -186,6 +186,41 @@ draw_radio (cairo_t *cr,
   cairo_stroke (cr);
 }
 
+static void
+draw_edit (cairo_t *cr,
+           int      part,
+           int      state,
+           int      width,
+           int      height)
+{
+  int xborder = gtk_win32_get_sys_metric (GTK_WIN32_SYS_METRIC_CXBORDER);
+  int yborder = gtk_win32_get_sys_metric (GTK_WIN32_SYS_METRIC_CYBORDER);
+
+  cairo_rectangle (cr, 0, 0, width, height);
+  gtk_cairo_set_source_sys_color (cr, (state == 6 || state == 4) ? GTK_WIN32_SYS_COLOR_BTNFACE
+                                                                 : GTK_WIN32_SYS_COLOR_WINDOW);
+  cairo_fill_preserve (cr);
+
+  cairo_rectangle (cr, width - xborder, yborder,
+                   - (width - 2 * xborder), height - 2 * yborder);
+  gtk_cairo_set_source_sys_color (cr, GTK_WIN32_SYS_COLOR_WINDOWFRAME);
+  cairo_fill (cr);
+}
+
+static void
+draw_edit_noborder (cairo_t *cr,
+                    int      part,
+                    int      state,
+                    int      width,
+                    int      height)
+{
+
+  cairo_rectangle (cr, 0, 0, width, height);
+  gtk_cairo_set_source_sys_color (cr, (state == 6 || state == 4) ? GTK_WIN32_SYS_COLOR_BTNFACE
+                                                                 : GTK_WIN32_SYS_COLOR_WINDOW);
+  cairo_fill (cr);
+}
+
 static void
 draw_window (cairo_t *cr,
              int      part,
@@ -270,6 +305,12 @@ static GtkWin32ThemePart theme_parts[] = {
   { "button",  1,  0, { 3, 3, 3, 3 }, draw_button },
   { "button",  2, 13, { 0, 0, 0, 0 }, draw_radio },
   { "button",  3, 13, { 0, 0, 0, 0 }, draw_check },
+  { "edit",    1,  0, { 0, 0, 0, 0 }, draw_edit },
+  { "edit",    3,  0, { 0, 0, 0, 0 }, draw_edit_noborder },
+  { "edit",    6,  0, { 0, 0, 0, 0 }, draw_edit },
+  { "edit",    7,  0, { 0, 0, 0, 0 }, draw_edit },
+  { "edit",    8,  0, { 0, 0, 0, 0 }, draw_edit },
+  { "edit",    9,  0, { 0, 0, 0, 0 }, draw_edit },
   { "tooltip", 1,  0, { 0, 0, 0, 0 }, draw_tooltip },
   { "window",  1,  0, { 0, 0, 0, 0 }, draw_window },
   { "window", 15,  0, { 0, 0, 0, 0 }, draw_window_button },
index 1c5026f22f2083c6e7659ca4f0c25883524a8af7..41b343fec4bfd4439a1838bf6ab5d23034d18a0c 100644 (file)
@@ -467,28 +467,42 @@ scrollbar.vertical slider:disabled {
 
 /* Entry */
 
-/* We apply the border as a border combined with the background so that
-   gtk_entry_set_has_frame works */
-
+textview.view,
 entry {
-    border-width: 1px;
-    border-style: solid;
-    border-image: -gtk-win32-theme-part(edit, 6, 1)  1 1 1 1 stretch;
-    background-image: -gtk-win32-theme-part(edit, 6, 1, margins(-1 -1 -1 -1));
-    padding: 2px;
+    background-image: -gtk-win32-theme-part(edit, 1, 1);
+    /* The 1em/3 is the "margin" that Windows uses. I'm pretty sure that's the "ABC width"
+       of the font. But we don't get those fancy things in CSS. */
+    padding: -gtk-win32-size(edit, cyedge) calc(-gtk-win32-size(edit, cxedge) + 1em/3);
 }
+
+textview.view:focus,
+entry:focus {
+    background-image: -gtk-win32-theme-part(edit, 1, 3);
+}
+
+textview.view:disabled,
 entry:disabled {
-    border-image: -gtk-win32-theme-part(edit, 6, 4)  1 1 1 1 stretch;
-    background-image: -gtk-win32-theme-part(edit, 6, 4, margins(-1 -1 -1 -1));
-    color: #a7aba7;
+    background-image: -gtk-win32-theme-part(edit, 1, 4);
+    color: -gtk-win32-color(edit, graytext);
 }
-entry:hover {
-    border-image: -gtk-win32-theme-part(edit, 6, 2)  1 1 1 1 stretch;
-    background-image: -gtk-win32-theme-part(edit, 6, 2, margins(-1 -1 -1 -1));
+
+selection {
+    background: -gtk-win32-color(edit, highlight);
+    color: -gtk-win32-color(edit, highlighttext);
 }
-entry:focus {
-    border-image: -gtk-win32-theme-part(edit, 6, 3)  1 1 1 1 stretch;
-    background-image: -gtk-win32-theme-part(edit, 6, 3, margins(-1 -1 -1 -1));
+
+entry.flat {
+  padding: 0px;
+  background-image: -gtk-win32-theme-part(edit, 3, 1);
+}
+
+entry.flat:focus {
+    background-image: -gtk-win32-theme-part(edit, 3, 3);
+}
+
+entry.flat:disabled {
+    background-image: -gtk-win32-theme-part(edit, 3, 4);
+    color: -gtk-win32-color(edit, graytext);
 }
 
 /* Spibuttons */